package cn.lhl.task;

import cn.hutool.core.util.NumberUtil;
import cn.lhl.fm.entity.TableTestEntity;
import cn.lhl.fm.mapper.TableTestMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TaskDemo {

	@Autowired
	TableTestMapper mapper;

	//@Scheduled(cron = "0/5 * * * * *")
	public void synTask() {

		/**
		 * 插入数据
		 */
		TableTestEntity entity = new TableTestEntity();
		entity.setColumn2("哈哈");
		entity.setColumn3(NumberUtil.toBigDecimal("123"));
		mapper.insert(entity);
		log.info("log_________");

	}


	@Scheduled(cron = "0/5 * * * * *")
	public void synTasks() {

		/**
		 * 查询 id = 1 的数据
		 */
		TableTestEntity result1 = mapper.findOne(
				mapper.query()
				.where.column1().eq(1L).end());
		/**
		 * 控制台直接打印出查询结果
		 */
		System.out.println("1. result1:" + result1.toString());
		log.info("log_________");

	}


}
